package com.woniuxy.car.boss.app.apiImpl;

import cn.hutool.core.bean.BeanUtil;
import com.woniuxy.car.boss.app.util.GetToken;
import com.woniuxy.car.boss.client.StoreBossClient;
import com.woniuxy.car.boss.param.store.BossApprovalApplicationParam;
import com.woniuxy.car.boss.param.store.BossApprovalStoreServiceApplicationParam;
import com.woniuxy.car.common.resultcode.Result;
import com.woniuxy.car.store.client.StoreManageClient;
import com.woniuxy.car.store.client.StoreQueryClient;
import com.woniuxy.car.store.client.StoreServiceManageClient;
import com.woniuxy.car.store.client.StoreServiceQueryClient;
import com.woniuxy.car.store.client.param.ApprovalApplicationParam;
import com.woniuxy.car.store.client.param.ApprovalStoreServiceApplicationParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
public class StoreBossApiImpl implements StoreBossClient {
    @Resource
    private StoreManageClient storeManageClient;
    @Resource
    private StoreQueryClient storeQueryClient;
    @Resource
    private StoreServiceManageClient storeServiceManageClient;
    @Resource
    private StoreServiceQueryClient storeServiceQueryClient;
    @Override
    public Result approvalApplication(BossApprovalApplicationParam bossApprovalApplicationParam) {
        log.info("请求参数：{}", bossApprovalApplicationParam);
        ApprovalApplicationParam approvalApplicationParam = BeanUtil.copyProperties(bossApprovalApplicationParam, ApprovalApplicationParam.class);
        Integer bossToken = GetToken.getBossToken();
        approvalApplicationParam.setPlatformAccountId(bossToken);
        return storeManageClient.approvalApplication(approvalApplicationParam);
    }

    @Override
    public Result findAllStore() {
        log.info("无参数");
        return storeQueryClient.getAllStoreInfo();
    }

    @Override
    public Result approvalStoreServiceApplication(BossApprovalStoreServiceApplicationParam bossApprovalStoreServiceApplicationParam) {
        log.info("请求参数：{}", bossApprovalStoreServiceApplicationParam);
        ApprovalStoreServiceApplicationParam approvalStoreServiceApplicationParam = BeanUtil.copyProperties(bossApprovalStoreServiceApplicationParam, ApprovalStoreServiceApplicationParam.class);
        Integer bossToken = GetToken.getBossToken();
        approvalStoreServiceApplicationParam.setPlatformAccountId(bossToken);
        return storeServiceManageClient.approvalStoreServiceApplication(approvalStoreServiceApplicationParam);
    }

    @Override
    public Result getAllServiceApplication() {
        log.info("无参数");
        return storeServiceQueryClient.getAllServiceApplication();
    }

    @Override
    public Result getAllStoreApplication() {
        log.info("无参数");
        return storeServiceQueryClient.getAllStoreApplication();
    }


}
